package everyday.nowcoder;

/**
 * @Author: wenjingyuan
 * @Date: 2022/11/23/11:22
 * @Description:NC29 二维数组中的查找
 */
public class NC29 {
    public boolean Find(int target, int [][] array) {
        if(array.length==0)return false;
        if(array[0].length==0) return false;
        int n=array.length;
        int m=array[0].length;
        for (int i = n-1, j=0; i >=0 && j< m; ) {
            if(target>array[i][j]){
              j++;
            }else if(target<array[i][j]){
                i--;
            }else{
                return true;
            }
        }
        return false;
    }
}
